package com.ilxqx.framework.amqp.po;

import com.ilxqx.framework.system.service.MailService;
import com.ilxqx.framework.util.SpringUtils;

import java.io.Serializable;

/**
 * 邮件发送任务
 * @author venus
 */
public class EmailSendingTask implements SysTask, Serializable {

    private static final long serialVersionUID = -5309983232938567667L;

    /**
     * 邮件收件人
     */
    private String to;

    /**
     * 邮件的主题
     */
    private String subject;

    /**
     * 邮件内容
     */
    private String content;

    public EmailSendingTask(String to, String subject, String content) {
        this.to = to;
        this.subject = subject;
        this.content = content;
    }

    /**
     * 执行任务
     */
    @Override
    public void perform() {
        // 发送邮件
        MailService mailService = SpringUtils.getBean(MailService.class);
        mailService.sendHtmlMail(to, subject, content);
    }

}
